package com.horay.springbootdemo.async.context.controller;

import com.horay.springbootdemo.common.result.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * Callable异步控制器
 *
 * @author heyingcheng
 * @date 2019/9/2 0:35
 */
@Slf4j
@RestController
@RequestMapping("async/context")
public class CallableAsyncController {

    @GetMapping("callable")
    public Callable<ResultBody<String>> callable() {
        Callable<ResultBody<String>> callable = () -> {
            log.info("CallableAsyncController.callable方法内部线程：" + Thread.currentThread().getName());
            return new ResultBody("CallableAsyncController.callable方法异步的请求响应");
        };
        return callable;
    }

}
